package com.jz.community.modulemine.rechargephone.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.modulemine.money.bean.MoneyInfoBean;
import com.jz.community.modulemine.money.bean.MoneyRechargeBean;
import com.jz.community.modulemine.rechargephone.bean.PhoneFareBean;
import com.jz.community.modulemine.rechargephone.bean.PhonePriceBean;
import com.jz.community.modulemine.rechargephone.model.PhoneModel;
import com.jz.community.modulemine.rechargephone.model.PhoneModelImp;
import com.jz.community.modulemine.rechargephone.ui.PhoneFareView;

public class PhoneFarePresenter extends BaseLifeCyclePresent<PhoneFareView.View> implements PhoneFareView.Presenter {
    private PhoneFareView.View view;
    private PhoneModel phoneModel;

    public PhoneFarePresenter(PhoneFareView.View view) {
        this.view = view;
        this.phoneModel = new PhoneModelImp(view.getContext());
    }

    @Override
    public void initPhoneData(int page, int size) {
        phoneModel.initPhoneData(page, size, new OnLoadListener<PhonePriceBean>() {
            @Override
            public void onSuccess(PhonePriceBean phonePriceBean) {
                view.setPhoneData(phonePriceBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.phoneDataFail(msg);
            }
        });

    }

    @Override
    public void initMoneyData() {
        phoneModel.initMyMoneyData(new OnLoadListener<MoneyInfoBean>() {
            @Override
            public void onSuccess(MoneyInfoBean moneyInfoBean) {
                view.setMoneyData(moneyInfoBean);

            }

            @Override
            public void onFail(String msg, int code) {
                view.MoneyDataFail(msg);

            }
        });
    }

    @Override
    public void rechargePhone(String phone, int type, String id) {
        phoneModel.rechargePhone(phone, type, id, new OnLoadListener<PhoneFareBean>() {
            @Override
            public void onSuccess(PhoneFareBean phoneFareBean) {
                view.PhoneFareSuccess(phoneFareBean);

            }

            @Override
            public void onFail(String msg, int code) {
                view.PhoneFareFail(msg);

            }
        });

    }
}
